package tcp;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

/**
 * @author 美女
 * @date 2022/05/15 14:22
 **/
public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket=new Socket("127.0.0.1",9090);//本地ip和服务器端口
        InputStream is = socket.getInputStream();
        Scanner scanner=new Scanner(is,"UTF-8");
        OutputStream os = socket.getOutputStream();
        OutputStreamWriter writer=new OutputStreamWriter(os,"UTF-8");
        PrintWriter printWriter=new PrintWriter(writer);
        //客户端先发送请求
        printWriter.printf("我是Java19班的\r\napple\r\n");
        printWriter.flush();
        //读取响应
        String header = scanner.nextLine();//读到的是 好的
        String word=scanner.nextLine();//苹果
        System.out.println(word);
        socket.close();
    }
}
